package com.chain.BrotherExchange.viewmodel;

import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.arch.lifecycle.MutableLiveData;
import android.support.annotation.NonNull;

import com.chain.BrotherExchange.data.DataRepository;
import com.chain.BrotherExchange.data.Resource;
import com.chain.BrotherExchange.data.model.ChargeMoney;
import com.chain.BrotherExchange.utils.Androids;

/**
 * 充币
 */
public class ChargeMoneyViewModel extends AndroidViewModel {

    private final int uid = Androids.LocalConfig.getUid();
    private final String token = Androids.LocalConfig.getToken();

    private MutableLiveData<Resource<ChargeMoney.DataBean>> mChargeMoneyLiveData;

    public ChargeMoneyViewModel(@NonNull Application application) {
        super(application);
        mChargeMoneyLiveData = new MutableLiveData<>();
    }

    public MutableLiveData<Resource<ChargeMoney.DataBean>> chargeMoney(String id) {
        DataRepository.get().chargeMoney(uid, token, id, result -> {
            if (result.isSucceed()) {
                mChargeMoneyLiveData.setValue(Resource.success(result.getData()));
            } else {
                mChargeMoneyLiveData.setValue(Resource.error(""));
            }
        });
        
        return mChargeMoneyLiveData;
    }
}
